<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="服务合同编号" prop="scNo">
        <el-input
          v-model="queryParams.scNo"
          placeholder="请输入服务合同编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="签约日期" prop="contractDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.contractDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择签约日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="合同类型" prop="contractType">
        <el-select v-model="queryParams.contractType" placeholder="请选择合同类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="合同状态" prop="contractStatus">
        <el-select v-model="queryParams.contractStatus" placeholder="请选择合同状态" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="负责人" prop="follower">
        <el-input
          v-model="queryParams.follower"
          placeholder="请输入负责人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['crm:servicecontract:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['crm:servicecontract:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['crm:servicecontract:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['crm:contract:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="contractList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
                  <el-table-column label="服务合同编号" align="center" class-name="small-padding fixed-width" prop="scNo">
                          <template slot-scope="scope">
                            <el-button
                              size="mini"
                              type="text"
                              @click="getServiceContractInfo1(scope.row)"
                              v-hasPermi="['system:contract:list']"
                            >{{scope.row.scNo}}</el-button>
                          </template>
                  </el-table-column>
                  <el-table-column label="客户名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                          <template slot-scope="scope">
                            <el-button
                              size="mini"
                              type="text"
                              @click="getCustomerInfo1(scope.row)"
                              v-hasPermi="['system:contract:list']"
                            >{{scope.row.customerName}}</el-button>
                          </template>
                  </el-table-column>
      <el-table-column label="签约日期" align="center" prop="contractDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.contractDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合同类型" align="center" prop="contractType" />
      <el-table-column label="合同状态" align="center" prop="contractStatus" />
      <el-table-column label="负责人" align="center" prop="follower" />
      <el-table-column label="修改时间" align="center" prop="updateTime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['crm:servicecontract:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['crm:servicecontract:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-dialog :title="title" :visible.sync="dialogVisible" width="800px" append-to-body>
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane label="客户详情" name="first">
              <el-collapse v-model="activeNames" @change="handleChange">
                <el-collapse-item title="基本信息" name="1">
               <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                  <el-descriptions-item >
                    <template slot="label">
                          客户名称
                    </template>
                    {{CustomerInfo.customerName}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                          上级单位
                    </template>
                    {{CustomerInfo.superior}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                          客户编号
                    </template>
                    {{CustomerInfo.customerNo}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                     <template slot="label">
                          客户状态
                     </template>
                     {{CustomerInfo.customerStatus}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                     <template slot="label">
                          客户类型
                     </template>
                     {{CustomerInfo.customerType}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                     <template slot="label">
                          销售负责人
                     </template>
                     {{CustomerInfo.staffFollower}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                     <template slot="label">
                          重要级别
                     </template>
                     {{CustomerInfo.level}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                     <template slot="label">
                          最新服务时间
                     </template>
                     {{CustomerInfo.contactDateLast}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                     <template slot="label">
                          最新分配人
                     </template>
                     {{CustomerInfo.followLast}}
                  </el-descriptions-item>
                  <el-descriptions-item>
                    <template slot="label">
                          是否新客户
                    </template>
                    {{CustomerInfo.isNewCu}}
                  </el-descriptions-item>
                </el-descriptions>
               </el-form>
               </el-collapse-item>

                <el-collapse-item title="工商信息" name="2">
                <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                  <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                纳税人识别号
                          </template>
                          {{CustomerInfo.taxpayerNo}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                注册时间
                          </template>
                          {{CustomerInfo.registerDate}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                公司性质
                          </template>
                          {{CustomerInfo.companyNature}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                客户规模
                          </template>
                          {{CustomerInfo.customerSize}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                法定代表人
                          </template>
                          {{CustomerInfo.legalRepresent}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                注册资金
                          </template>
                          {{CustomerInfo.registerAc}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                所属行业
                          </template>
                          {{CustomerInfo.industry}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                经营范围
                          </template>
                          {{CustomerInfo.businessScope}}
                        </el-descriptions-item>
                  </el-descriptions>
               </el-form>
                </el-collapse-item>

                <el-collapse-item title="动态信息" name="3">
                  <el-form ref="customerList" :model="customerList" :rules="rules" label-width="80px">
                    <el-descriptions class="margin-top"  :column="2" :size="size" border>
                            <el-descriptions-item >
                              <template slot="label">
                                    下次回访日期
                              </template>
                                {{CustomerInfo.nextRevisitTime}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    未联系天数
                              </template>
                              177
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    最新联系日期
                              </template>
                              {{CustomerInfo.contactDateLast}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    最新进展
                              </template>
                              {{CustomerInfo.lastProgress}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    创建时间
                              </template>
                              {{CustomerInfo.createTime}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    修改时间
                              </template>
                              {{updateTime}}
                            </el-descriptions-item>
                    </el-descriptions>
                  </el-form>
                </el-collapse-item>

                <el-collapse-item title="首要联系人" name="4">
                  <el-form ref="FirstContactInfo" :model="FirstContactInfo" :rules="rules" label-width="80px">
                    <el-descriptions class="margin-top"  :column="2" :size="size" border>
                            <el-descriptions-item >
                              <template slot="label">
                                    联系人姓名
                              </template>
                              {{FirstContactInfo.telName}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    联系人职务
                              </template>
                              {{FirstContactInfo.position}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    联系人称谓
                              </template>
                              {{FirstContactInfo.conSex}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    办公电话
                              </template>
                              {{FirstContactInfo.officePhone}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    联系人手机
                              </template>
                              {{FirstContactInfo.telephone}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    联系人住址
                              </template>
                              {{FirstContactInfo.conAddress}}
                            </el-descriptions-item>
                            <el-descriptions-item >
                              <template slot="label">
                                    联系人Email
                              </template>
                              {{FirstContactInfo.conEmail}}
                            </el-descriptions-item>
                    </el-descriptions>
                  </el-form>
                </el-collapse-item>

                <el-collapse-item title="地址信息" name="5">
                          <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            国家
                                      </template>
                                      {{CustomerInfo.country}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            省份
                                      </template>
                                      {{CustomerInfo.province}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            城市
                                      </template>
                                      {{CustomerInfo.city}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            区域
                                      </template>
                                      {{CustomerInfo.region}}
                                    </el-descriptions-item>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            详细地址
                                      </template>
                                      {{CustomerInfo.address}}
                                    </el-descriptions-item>
                            </el-descriptions>
                          </el-form>
                        </el-collapse-item>

                            <el-collapse-item title="备注信息" name="6">
                          <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            备注
                                      </template>
                                      {{CustomerInfo.markInfo}}
                                    </el-descriptions-item>
                            </el-descriptions>
                          </el-form>
                         </el-collapse-item>

                         <el-collapse-item title="附件信息" name="7">
                          <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            附件信息
                                      </template>
                                      {{CustomerInfo.enclosureInfo}}
                                    </el-descriptions-item>
                            </el-descriptions>
                          </el-form>
                         </el-collapse-item>

                         <el-collapse-item title="服务合同信息" name="8">
                          <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            合同服务信息
                                      </template>
                                      {{CustomerInfo.serviceContractInfo}}
                                    </el-descriptions-item>
                            </el-descriptions>
                          </el-form>
                         </el-collapse-item>

                         <el-collapse-item title="评论信息" name="9">
                          <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                            <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                    <el-descriptions-item >
                                      <template slot="label">
                                            评论信息
                                      </template>
                                      {{CustomerInfo.comment}}
                                    </el-descriptions-item>
                            </el-descriptions>
                          </el-form>
                         </el-collapse-item>

               </el-collapse>
              </el-tab-pane>

              <el-tab-pane label="联系人" name="10">
                <el-form ref="Contact" :model="Contact" :rules="rules" label-width="100px">
                  <el-table :data="Contact" @selection-change="handleSelectionChange" empty-text="暂无数据">
                                <el-table-column label="联系人姓名" align="center" prop="telName" >
                                              <template slot-scope="scope">
                                                <el-button
                                                  size="mini"
                                                  type="text"
                                                  @click="getContactInfo(scope.row)"
                                                  v-hasPermi="['system:return:list']"
                                                >{{scope.row.telName}}</el-button>
                                              </template>
                                </el-table-column>
                    <el-table-column label="联系人编号" align="center" prop="telNo" />
                    <el-table-column label="职务" align="center" prop="position" />
                    <el-table-column label="手机" align="center" prop="telephone" />
                    <el-table-column label="销售负责人" align="center" prop="staffFollower" />
                    <el-table-column label="修改时间" align="center" prop="updateTime" />
                    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                      <template slot-scope="scope">
                        <el-button
                          size="mini"
                          type="text"
                          icon="el-icon-edit"
                          @click="handleUpdate(scope.row)"
                          v-hasPermi="['system:customer:edit']"
                        >修改</el-button>
                        <el-button
                          size="mini"
                          type="text"
                          icon="el-icon-delete"
                          @click="handleDelete(scope.row)"
                          v-hasPermi="['system:customer:remove']"
                        >删除</el-button>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-form>
              </el-tab-pane>

              <el-tab-pane label="跟进记录" name="11">
              <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                        <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                          <el-table-column label="主题" align="center" prop="theme"/>
                                                     <el-table-column label="联系人姓名" align="center" prop="telName" >
                                                                    <template slot-scope="scope">
                                                                      <el-button
                                                                        size="mini"
                                                                        type="text"
                                                                        @click="getContactInfo(scope.row)"
                                                                        v-hasPermi="['system:quotation:list']"
                                                                      >{{scope.row.telName}}</el-button>
                                                                    </template>
                                                      </el-table-column>
                          <el-table-column label="客户状态" align="center" prop="status" />
                          <el-table-column label="联系方式" align="center" prop="howContact" />
                          <el-table-column label="联系日期" align="center" prop="contactDate" />
                          <el-table-column label="负责人" align="center" prop="staffFollower" />
                          <el-table-column label="跟进记录" align="center" prop="followRecord" />
                          <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                        </el-table>
                      </el-form>
              </el-tab-pane>
        </el-tabs>
             <div slot="footer" class="dialog-footer">
               <el-button type="primary" @click="submitForm1">确 定</el-button>
               <el-button @click="cancel1">取 消</el-button>
             </div>
          </el-dialog>

 <el-dialog :title="title" :visible.sync="contactDialog" width="800px" append-to-body>
           <el-tabs v-model="activeName" @tab-click="handleClick">
             <el-tab-pane label="联系人" name="conFirst">
             <el-collapse v-model="activeNames" @change="handleChange">
               <el-collapse-item title="联系人详情" name="con1">
                 <el-form ref="ContactByTelName" :model="ContactByTelName" :rules="rules" label-width="80px">
                   <el-descriptions class="margin-top"  :column="2" :size="size" border>
                           <el-descriptions-item >
                             <template slot="label">
                                   联系人编号
                             </template>
                             {{ContactByTelName.telNo}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   联系人姓名
                             </template>
                             {{ContactByTelName.telName}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   联系人称谓
                             </template>
                             {{ContactByTelName.conSex}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   客户名称
                             </template>
                             {{ContactByTelName.customerName}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   联系人手机
                             </template>
                             {{ContactByTelName.telephone}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   联系人职务
                             </template>
                             {{ContactByTelName.position}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   销售负责人
                             </template>
                             {{ContactByTelName.staffFollower}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   办公电话
                             </template>
                             {{ContactByTelName.officePhone}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   Email
                             </template>
                             {{ContactByTelName.conEmail}}
                           </el-descriptions-item>
                           <el-descriptions-item >
                             <template slot="label">
                                   修改时间
                             </template>
                             {{ContactByTelName.updateTime}}
                           </el-descriptions-item>
                   </el-descriptions>
                 </el-form>
               </el-collapse-item>

               <el-collapse-item title="地址信息" name="con2">
                 <el-form ref="CustomerInfo" :model="CustomerInfo" :rules="rules" label-width="80px">
                             <el-descriptions class="margin-top"  :column="2" :size="size" border>
                                     <el-descriptions-item >
                                       <template slot="label">
                                             国家
                                       </template>
                                       {{CustomerInfo.country}}
                                     </el-descriptions-item>
                                     <el-descriptions-item >
                                       <template slot="label">
                                             省份
                                       </template>
                                       {{CustomerInfo.province}}
                                     </el-descriptions-item>
                                     <el-descriptions-item >
                                       <template slot="label">
                                             城市
                                       </template>
                                       {{CustomerInfo.city}}
                                     </el-descriptions-item>
                                     <el-descriptions-item >
                                       <template slot="label">
                                             区域
                                       </template>
                                       {{CustomerInfo.region}}
                                     </el-descriptions-item>
                                     <el-descriptions-item >
                                       <template slot="label">
                                             联系人地址
                                       </template>
                                       {{ContactByTelName.conAddress}}
                                     </el-descriptions-item>
                             </el-descriptions>
                 </el-form>
               </el-collapse-item>
               </el-collapse>
           </el-tab-pane>
             <el-tab-pane label="跟进记录" name="conSecond">
             <el-form ref="FollowRecord" :model="FollowRecord" :rules="rules" label-width="100px">
                       <el-table :data="FollowRecord" @selection-change="handleSelectionChange" empty-text="暂无数据">
                         <el-table-column label="主题" align="center" prop="theme"/>
                                     <el-table-column label="客户名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                                             <template slot-scope="scope">
                                               <el-button
                                                 size="mini"
                                                 type="text"
                                                 @click="getCustomerInfo1(scope.row)"
                                                 v-hasPermi="['system:quotation:list']"
                                               >{{scope.row.customerName}}</el-button>
                                             </template>
                                     </el-table-column>
                         <el-table-column label="客户状态" align="center" prop="status" />
                         <el-table-column label="联系方式" align="center" prop="howContact" />
                         <el-table-column label="联系日期" align="center" prop="contactDate" />
                         <el-table-column label="负责人" align="center" prop="staffFollower" />
                         <el-table-column label="跟进记录" align="center" prop="followRecord" />
                         <el-table-column label="最新修改时间" align="center" prop="updateTime" />
                       </el-table>
                     </el-form>
             </el-tab-pane>
       </el-tabs>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="submitForm2">确 定</el-button>
              <el-button @click="cancel2">取 消</el-button>
            </div>
         </el-dialog>

<el-dialog :title="title" :visible.sync="productVisible" width="800px" append-to-body>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="产品详情" name="proFirst">
          <el-collapse v-model="activeNames" @change="handleChange">
            <el-collapse-item title="基本信息" name="p1">
           <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
            <el-descriptions class="margin-top"  :column="2" :size="size" border>
              <el-descriptions-item >
                <template slot="label">
                      产品名称
                </template>
                {{ProductInfo.productName}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      产品编号
                </template>
                {{ProductInfo.productNo}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      编码或条形码
                </template>
                {{ProductInfo.encrypt}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      产品类别
                 </template>
                 {{ProductInfo.productType}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      规格型号
                 </template>
                 {{ProductInfo.productModel}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      计量单位
                 </template>
                 {{ProductInfo.measureUnit}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      禁用
                 </template>
                 {{ProductInfo.isDisable}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      创建人
                 </template>
                 {{ProductInfo.creator}}
              </el-descriptions-item>
              <el-descriptions-item>
                 <template slot="label">
                      创建时间
                 </template>
                 {{ProductInfo.createTime}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      修改时间
                </template>
                {{ProductInfo.updateTime}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                      最新更新人
                </template>
                {{ProductInfo.updatePer}}
              </el-descriptions-item>
            </el-descriptions>
           </el-form>
           </el-collapse-item>

            <el-collapse-item title="价格信息" name="p2">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                产品报价（RMB）
                          </template>
                            {{ProductInfo.productOffer}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                参考成本价（RMB）
                          </template>
                          {{ProductInfo.costPrice}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="存库信息" name="p3">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                总库存量
                          </template>
                            {{ProductInfo.totalStock}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                安全库存
                          </template>
                          {{ProductInfo.safeStock}}
                        </el-descriptions-item>
                        <el-descriptions-item >
                          <template slot="label">
                                负责人
                          </template>
                          {{ProductInfo.follower}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="产品图片信息" name="p4">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                产品图片
                          </template>
                            {{ProductInfo.productPhoto}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="备注信息" name="p5">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                备注信息
                          </template>
                            {{ProductInfo.remarkInfo}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>

            <el-collapse-item title="评论信息" name="p6">
              <el-form ref="ProductInfo" :model="ProductInfo" :rules="rules" label-width="80px">
                <el-descriptions class="margin-top"  :column="2" :size="size" border>
                        <el-descriptions-item >
                          <template slot="label">
                                评论信息
                          </template>
                            {{ProductInfo.comment}}
                        </el-descriptions-item>
                </el-descriptions>
              </el-form>
            </el-collapse-item>



           </el-collapse>
          </el-tab-pane>

          <el-tab-pane label="客户" name="p7">
            <el-form ref="CustomerInfoForProduct" :model="CustomerInfoForProduct" :rules="rules" label-width="80px">
                          <el-table :data="CustomerInfoForProduct" @selection-change="handleSelectionChange" empty-text="暂无数据">
                            <el-table-column label="客户名称" align="center" prop="customerName"/>
                            <el-table-column label="销售负责人" align="center" prop="staffFollower" />
                            <el-table-column label="重要级别" align="center" prop="level" />
                            <el-table-column label="未联系天数" align="center"  />
                            <el-table-column label="客户类型" align="center" prop="customerType" />
                            <el-table-column label="下次回访日期" align="center" prop="nextRevisitTime" />
                            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                              <template slot-scope="scope">
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-edit"
                                  @click="handleUpdate(scope.row)"
                                  v-hasPermi="['system:customer:edit']"
                                >修改</el-button>
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-delete"
                                  @click="handleDelete(scope.row)"
                                  v-hasPermi="['system:customer:remove']"
                                >删除</el-button>
                              </template>
                            </el-table-column>
                          </el-table>
                       </el-form>
          </el-tab-pane>

          <el-tab-pane label="联系人" name="p8">
            <el-form ref="Contact" :model="Contact" :rules="rules" label-width="80px">
                          <el-table :data="Contact" @selection-change="handleSelectionChange" empty-text="暂无数据">
                                                       <el-table-column label="联系人姓名" align="center" prop="telName" >
                                                                      <template slot-scope="scope">
                                                                        <el-button
                                                                          size="mini"
                                                                          type="text"
                                                                          @click="getContactInfo(scope.row)"
                                                                          v-hasPermi="['system:quotation:list']"
                                                                        >{{scope.row.telName}}</el-button>
                                                                      </template>
                                                        </el-table-column>
                            <el-table-column label="客户名称" align="center" prop="customerName" />
                            <el-table-column label="联系人编号" align="center" prop="telNo" />
                            <el-table-column label="职务" align="center" prop="position" />
                            <el-table-column label="手机" align="center" prop="telephone" />
                            <el-table-column label="销售负责人" align="center" prop="staffFollower" />
                            <el-table-column label="修改时间" align="center" prop="updateTime" />
                            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                              <template slot-scope="scope">
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-edit"
                                  @click="handleUpdate(scope.row)"
                                  v-hasPermi="['system:customer:edit']"
                                >修改</el-button>
                                <el-button
                                  size="mini"
                                  type="text"
                                  icon="el-icon-delete"
                                  @click="handleDelete(scope.row)"
                                  v-hasPermi="['system:customer:remove']"
                                >删除</el-button>
                              </template>
                            </el-table-column>
                          </el-table>
                       </el-form>
          </el-tab-pane>

    </el-tabs>
         <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="productSubmit">确 定</el-button>
           <el-button @click="productCancel">取 消</el-button>
         </div>
      </el-dialog>

 <el-dialog :title="title" :visible.sync="ServiceContractVisible" width="800px" append-to-body>
         <el-tabs v-model="activeName" @tab-click="handleClick">
           <el-tab-pane label="详情" name="ContractInfoFirst">
           <el-collapse v-model="activeNames" @change="handleChange">
             <el-collapse-item title="基本信息" name="service1">
            <el-form ref="ServiceContractInfo" :model="ServiceContractInfo" :rules="rules" label-width="80px">
             <el-descriptions class="margin-top"  :column="2" :size="size" border>
               <el-descriptions-item >
                 <template slot="label">
                       服务合同编号
                 </template>
                 {{ServiceContractInfo.scNo}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       客户名称
                 </template>
                 {{ServiceContractInfo.customerName}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       联系人姓名
                 </template>
                 {{ServiceContractInfo.telName}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       合同订单
                  </template>
                  {{ServiceContractInfo.contractNo}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       合同类型
                  </template>
                  {{ServiceContractInfo.contractType}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       签约日期
                  </template>
                  {{ServiceContractInfo.contractDate}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       合同状态
                  </template>
                  {{ServiceContractInfo.contractStatus}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       负责人
                  </template>
                  {{ServiceContractInfo.follower}}
               </el-descriptions-item>
               <el-descriptions-item>
                  <template slot="label">
                       收款日期
                  </template>
                  {{ServiceContractInfo.collectionDate}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       创建时间
                 </template>
                 {{ServiceContractInfo.createTime}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       出库状态
                 </template>
                 {{ServiceContractInfo.checkoutStatus}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       服务开始日期
                 </template>
                 {{ServiceContractInfo.beginDate}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       服务到期日期
                 </template>
                 {{ServiceContractInfo.endDate}}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
                       修改时间
                 </template>
                 {{ServiceContractInfo.updateTime}}
               </el-descriptions-item>
             </el-descriptions>
            </el-form>
            </el-collapse-item>

             <el-collapse-item title="动态信息" name="service2">
               <el-form ref="ServiceContractInfo" :model="ServiceContractInfo" :rules="rules" label-width="80px">
                 <el-descriptions class="margin-top"  :column="2" :size="size" border>
                         <el-descriptions-item >
                           <template slot="label">
                                 已服务次数
                           </template>
                             {{ServiceContractInfo.yserviceTimes}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 应服务次数
                           </template>
                             {{ServiceContractInfo.sserviceTimes}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 已收金额
                           </template>
                             {{ServiceContractInfo.collectionAcy}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 应收金额
                           </template>
                             {{ServiceContractInfo.collectionAcs}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 已发货金额
                           </template>
                             {{ServiceContractInfo.ydeliverAmount}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 未发货金额
                           </template>
                             {{ServiceContractInfo.wdeliverAmount}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 未发货数量
                           </template>
                             {{ServiceContractInfo.wdeliverCount}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 已发货数量
                           </template>
                             {{ServiceContractInfo.ydeliverCount}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 已开票金额
                           </template>
                             {{ServiceContractInfo.yinvoiceAmount}}
                         </el-descriptions-item>
                         <el-descriptions-item >
                           <template slot="label">
                                 未开票金额
                           </template>
                             {{ServiceContractInfo.winvoiceAmount}}
                         </el-descriptions-item>
                 </el-descriptions>
               </el-form>
             </el-collapse-item>

             <el-collapse-item title="条款与条件" name="service3">
               <el-form ref="ServiceContractInfo" :model="ServiceContractInfo" :rules="rules" label-width="80px">
                 <el-descriptions class="margin-top"  :column="2" :size="size" border>
                         <el-descriptions-item >
                           <template slot="label">
                                 条款与条件
                           </template>
                             {{ServiceContractInfo.condition}}
                         </el-descriptions-item>
                 </el-descriptions>
               </el-form>
             </el-collapse-item>

             <el-collapse-item title="产品" name="service4">
                 <el-form ref="QuatationProductInfo" :model="QuatationProductInfo" :rules="rules" label-width="100px">
                     <el-table :data="QuatationProductInfo" @selection-change="handleSelectionChange" empty-text="暂无数据">
                       <el-table-column type="selection" width="55" align="center" />
                                   <el-table-column label="产品名称" align="center" class-name="small-padding fixed-width" prop="customerName">
                                           <template slot-scope="scope">
                                             <el-button
                                               size="mini"
                                               type="text"
                                               @click="getProductInfo1(scope.row)"
                                               v-hasPermi="['system:quotation:list']"
                                             >{{scope.row.productName}}</el-button>
                                           </template>
                                   </el-table-column>
                       <el-table-column label="产品编号" align="center" prop="productNo" />
                       <el-table-column label="规格型号" align="center" prop="measureUnit" />
                       <el-table-column label="数量" align="center" prop="count" />
                       <el-table-column label="不含税单价" align="center" prop="unitPriceExTax" />
                       <el-table-column label="不含税金额" align="center" prop="accountExTax" />
                       <el-table-column label="折扣率" align="center" prop="discountRate" />
                       <el-table-column label="税额" align="center" prop="taxAmount" />
                       <el-table-column label="实际含税单价" align="center" prop="unitPrice" />
                       <el-table-column label="价税合计" align="center" prop="taxRevenue" />
                       <el-table-column label="描述" align="center" prop="description" />
                       <el-table-column label="增值税" align="center" prop="vat" />
                     </el-table>
                   </el-form>
               </el-form>
             </el-collapse-item>

             <el-collapse-item title="评论信息" name="service5">
               <el-form ref="ContractInfo" :model="ServiceContractInfo" :rules="rules" label-width="80px">
                 <el-descriptions class="margin-top"  :column="2" :size="size" border>
                         <el-descriptions-item >
                           <template slot="label">
                                 评论信息
                           </template>
                             {{ServiceContractInfo.comment}}
                         </el-descriptions-item>
                 </el-descriptions>
               </el-form>
             </el-collapse-item>


            </el-collapse>
           </el-tab-pane>

     </el-tabs>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="ServiceContractSubmit">确 定</el-button>
            <el-button @click="ServiceContractCancel">取 消</el-button>
          </div>
       </el-dialog>


    <!-- 添加或修改服务合同对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="服务合同编号" prop="scNo">
          <el-input v-model="form.scNo" placeholder="请输入服务合同编号" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="签约日期" prop="contractDate">
          <el-date-picker clearable size="small"
            v-model="form.contractDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择签约日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="合同类型" prop="contractType">
          <el-select v-model="form.contractType" placeholder="请选择合同类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="合同状态">
          <el-radio-group v-model="form.contractStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="负责人" prop="follower">
          <el-input v-model="form.follower" placeholder="请输入负责人" />
        </el-form-item>
        <el-divider content-position="center">顾客产品信息信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddCustomerProduct">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteCustomerProduct">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="customerProductList" :row-class-name="rowCustomerProductIndex" @selection-change="handleCustomerProductSelectionChange" ref="customerProduct">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
                     <el-table-column label="产品名称" prop="productName">
                      <template slot-scope="scope">
                                      <el-button
                                        size="mini"
                                        type="text"
                                        @click="getProductInfo1(scope.row)"
                                        v-hasPermi="['system:quotation:list']"
                                      >{{scope.row.productName}}</el-button>
                      </template>
                    </el-table-column>
                    <el-table-column label="产品名称(更改后)" prop="productName">
                      <template slot-scope="scope">
                                      <el-button
                                        size="mini"
                                        type="text"
                                        @click="getProductInfoChange(scope.row)"
                                        v-hasPermi="['system:quotation:list']"
                                      >{{scope.row.productNameChange}}</el-button>
                      </template>
                    </el-table-column>
          <el-table-column label="数量" prop="quantity">
            <template slot-scope="scope">
              <el-input v-model="scope.row.quantity" placeholder="请输入数量" />
            </template>
          </el-table-column>
          <el-table-column label="价税合计" prop="taxRevenue">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxRevenue" placeholder="请输入价税合计" />
            </template>
          </el-table-column>
          <el-table-column label="未出库数量" prop="uncheckoutNum">
            <template slot-scope="scope">
              <el-input v-model="scope.row.uncheckoutNum" placeholder="请输入未出库数量" />
            </template>
          </el-table-column>
          <el-table-column label="已出库数量" prop="checkoutNum">
            <template slot-scope="scope">
              <el-input v-model="scope.row.checkoutNum" placeholder="请输入已出库数量" />
            </template>
          </el-table-column>
          <el-table-column label="服务开始日" prop="serviceBdate">
            <template slot-scope="scope">
              <el-input v-model="scope.row.serviceBdate" placeholder="请输入服务开始日" />
            </template>
          </el-table-column>
          <el-table-column label="服务到期日" prop="serviceEdate">
            <template slot-scope="scope">
              <el-input v-model="scope.row.serviceEdate" placeholder="请输入服务到期日" />
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listContract, getContract, delContract, addContract, updateContract,getCustomerInfo,getFollowRecord,getContact,getFirstContactInfoByCustomerName,getContactByTelName,getProductInfoByName,getInfoByScNo,getQuatationProductInfoByName } from "@/api/crm/service/contract";

export default {
  name: "Contract",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedCustomerProduct: [],
      activeNames: ['1'],
      activeName: 'second',
      ProductInfo: {},
      ServiceContractInfo: {},
      productVisible: false,
      dialogVisible: false,
      CustomerInfo: {},
      FollowRecord: [],
      Contact: [],
      ContactObj: {},
      FirstContactInfo: {},
      contactDialog: false,
      ContactByTelName: {},
      QuatationProductInfo: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 服务合同表格数据
      contractList: [],
      // 顾客产品信息表格数据
      customerProductList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        scNo: null,
        customerName: null,
        contractDate: null,
        contractType: null,
        contractStatus: null,
        follower: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询服务合同列表 */
    getList() {
      this.loading = true;
      listContract(this.queryParams).then(response => {
        this.contractList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    submitForm1() {
    	this.dialogVisible = false;
    	this.Contact=[];
    	this.reset();
    },

    cancel1() {
    	this.dialogVisible = false;
    	this.Contact=[];
    	this.reset();
    },
                                                submitForm2() {
                                                  this.contactDialog = false;
                                                  this.reset();
                                                },

                        cancel2() {
                          this.contactDialog = false;
                          this.reset();
                        },
                        ServiceContractCancel(){
                          this.ServiceContractVisible=false;
                          this.reset();
                        },
                                                 productSubmit(){
                                                   this.productVisible=false;
                                                   this.Contact=[];
                                                   this.CustomerInfoForProduct=[];
                                                 },
                        productCancel(){
                          this.productVisible=false;
                          this.Contact=[];
                          this.CustomerInfoForProduct=[];
                        },
                        ServiceContractSubmit(){
                          this.ServiceContractVisible=false;
                          this.reset();
                        },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        scNo: null,
        customerName: null,
        contractDate: null,
        contractType: null,
        contractStatus: "0",
        follower: null,
        updateTime: null
      };
      this.customerProductList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
getCustomerInfo1(row){
	const customerName = row.customerName;
	const telName=row.telName;
	this.updateTime= row.updateTime;
	this.uncontactDays=row.uncontactDays;
    getCustomerInfo(customerName).then(response => {
    	this.CustomerInfo=response.data;
    	console.log(this.CustomerInfo)
    	this.dialogVisible=true;
    	this.title= "客户信息";
    	this.size='50';
    })
    getFollowRecord(customerName).then(response => {
    	let list=response.data;
        this.FollowRecord=response.data;
        this.dialogVisible=true;
        this.size='50';
    })
    getContact(customerName).then(response => {
    	this.ContactObj=response.data;
    	let list =response.data;
    	this.Contact.push(...response.data);
    	this.dialogVisible=true;
    	this.size='50';
    })
    getFirstContactInfoByCustomerName(customerName).then(response => {
    	this.FirstContactInfo=response.data;
        this.dialogVisible=true;
        this.size='50';
    })
},
 getContactInfo(row){
    this.contactDialog=true;
    const telName = row.telName;
                        const customerName = row.customerName;
                        this.updateTime= row.updateTime;
                        this.uncontactDays=row.uncontactDays;
              getContactByTelName(telName).then(response => {
                   this.ContactByTelName=response.data;
                   console.log(this.ContactByTelName)
                   this.size='50';
              })
                    getCustomerInfo(customerName).then(response => {
                        this.CustomerInfo=response.data;
                        console.log(this.CustomerInfo);
                        this.size='50';
                    })
                         getFollowRecord(customerName).then(response => {
                                             let list=response.data;
                                             this.FollowRecord=response.data;
                                             this.size='50';
                         })
    },
    getProductInfo1(row){
          this.productVisible=true;
          const productName=row.productName;
          const customerName=row.customerName;
          getProductInfoByName(productName).then(response =>{
            this.ProductInfo=response.data;
            this.size='50';
            this.title = "产品信息"
          })
                              getCustomerInfo(customerName).then(response => {
                                  const data=response.data;
                                  this.CustomerInfoForProduct.push(response.data);
                                  console.log(response.data);
                                  this.size='50';
                              })
                                    getContact(customerName).then(response => {
                                                        this.ContactObj=response.data;
                                                        let list =response.data;
                                                        this.Contact.push(...response.data);
                                                        this.size='50';
                                    })
        },

    getProductInfoChange(row){
          this.productVisible=true;
          const productName=row.productNameChange;
          const customerName=row.customerName;
          getProductInfoByName(productName).then(response =>{
            this.ProductInfo=response.data;
            this.size='50';
            this.title = "产品信息"
          })
                              getCustomerInfo(customerName).then(response => {
                                  const data=response.data;
                                  this.CustomerInfoForProduct.push(response.data);
                                  console.log(response.data);
                                  this.size='50';
                              })
                                    getContact(customerName).then(response => {
                                                        this.ContactObj=response.data;
                                                        let list =response.data;
                                                        this.Contact.push(...response.data);
                                                        this.size='50';
                                    })
        },
    getServiceContractInfo1(row){
      this.ServiceContractVisible=true;
      const scNo=row.scNo;
      const customerName=row.customerName;
      getInfoByScNo(scNo).then(response => {
          this.ServiceContractInfo=response.data;
          console.log(response.data)
          this.title='服务合同';
      })
            getQuatationProductInfoByName(customerName).then(response=>{
                  this.QuatationProductInfo=response.data;
                  console.log(this.QuatationProductInfo)
            })
    },



    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加服务合同";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getContract(id).then(response => {
        this.form = response.data;
        this.customerProductList = response.data.customerProductList;
        this.open = true;
        this.title = "修改服务合同";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.customerProductList = this.customerProductList;
          if (this.form.id != null) {
            updateContract(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addContract(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除服务合同编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delContract(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
	/** 顾客产品信息序号 */
    rowCustomerProductIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 顾客产品信息添加按钮操作 */
    handleAddCustomerProduct() {
      let obj = {};
      obj.productName = "";
      obj.productNameChange = "";
      obj.quantity = "";
      obj.taxRevenue = "";
      obj.uncheckoutNum = "";
      obj.checkoutNum = "";
      obj.serviceBdate = "";
      obj.serviceEdate = "";
      this.customerProductList.push(obj);
    },
    /** 顾客产品信息删除按钮操作 */
    handleDeleteCustomerProduct() {
      if (this.checkedCustomerProduct.length == 0) {
        this.$alert("请先选择要删除的顾客产品信息数据", "提示", { confirmButtonText: "确定", });
      } else {
        this.customerProductList.splice(this.checkedCustomerProduct[0].index - 1, 1);
      }
    },
    /** 单选框选中数据 */
    handleCustomerProductSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.customerProduct.clearSelection();
        this.$refs.customerProduct.toggleRowSelection(selection.pop());
      } else {
        this.checkedCustomerProduct = selection;
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('crm/contract/export', {
        ...this.queryParams
      }, `crm_contract.xlsx`)
    }
  }
};
</script>
